﻿<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	x:Class="Microsoft.Research.ScientificWorkflow.ManagementStudioControls.RegistryManagerModule.SearchUser"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" 
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    x:Name="SearchUserWindow" Width="410" Height="280" 
    WindowStyle="None" Background="{x:Null}" ResizeMode="NoResize" ShowInTaskbar="False"  WindowStartupLocation="CenterOwner" AllowsTransparency="True">

    <Window.Resources>
     
        <BooleanToVisibilityConverter x:Key="VisibilityConverter"></BooleanToVisibilityConverter>

        <Style x:Key="PopupCloseButton" BasedOn="{x:Null}" TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Fill="#FFCCCCCC" Stroke="{x:Null}" RadiusX="4.5" RadiusY="4.5" x:Name="rectangle"/>
                            <Rectangle Fill="#FF4F4F4F" Stroke="{x:Null}" RadiusX="0" RadiusY="0" Margin="8,3.5,7,3.5" RenderTransformOrigin="0.5,0.5">
                                <Rectangle.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                                        <SkewTransform AngleX="0" AngleY="0"/>
                                        <RotateTransform Angle="-34.039"/>
                                        <TranslateTransform X="0" Y="0"/>
                                    </TransformGroup>
                                </Rectangle.RenderTransform>
                            </Rectangle>
                            <Rectangle Fill="#FF4F4F4F" Stroke="{x:Null}" RadiusX="0" RadiusY="0" RenderTransformOrigin="0.5,0.5" Margin="8,3.5,7,3.5">
                                <Rectangle.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform ScaleX="-1" ScaleY="1"/>
                                        <SkewTransform AngleX="0" AngleY="0"/>
                                        <RotateTransform Angle="34.039"/>
                                        <TranslateTransform X="0" Y="0"/>
                                    </TransformGroup>
                                </Rectangle.RenderTransform>
                            </Rectangle>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsFocused" Value="True"/>
                            <Trigger Property="IsDefaulted" Value="True"/>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Fill" TargetName="rectangle" Value="#FFADADAD"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True"/>
                            <Trigger Property="IsEnabled" Value="False"/>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <ControlTemplate x:Key="TextBoxControlTemplate1" TargetType="{x:Type TextBox}">
            <Grid>
                <Border HorizontalAlignment="Stretch" Background="#FFFFFFFF" BorderBrush="#FFC8C8C8" CornerRadius="2,0,0,2" BorderThickness="1,1,0,1">
                    <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                </Border>
            </Grid>
        </ControlTemplate>
    </Window.Resources>

    <Grid x:Name="LayoutRoot" Background="{x:Null}">
        <Border BorderBrush="#FFBDBDBD" BorderThickness="1,1,2,2" CornerRadius="4,4,4,4">
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFF7F7F7" Offset="0"/>
                    <GradientStop Color="#FFF1F1F1" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="28"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="38"/>
                </Grid.RowDefinitions>
                <Border Name="brdrHeader" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Grid.Row="0" CornerRadius="4,4,0,0">
                    <Border.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FFF7F7F7" Offset="0"/>
                            <GradientStop Color="#FFE9E9E9" Offset="1"/>
                        </LinearGradientBrush>
                    </Border.Background>
                    <Grid>
                        <TextBlock HorizontalAlignment="Left" Margin="5,0,0,0" VerticalAlignment="Center" FontSize="14" Foreground="#FF5F5F5F" Text="Add Users " TextWrapping="Wrap"/>
						<Button HorizontalAlignment="Right" Margin="0,5.5,5,5.5" Style="{DynamicResource PopupCloseButton}" Width="17" Content="Button" Command="{Binding Path=CancelCommand}"/>
					</Grid>
                </Border>
                <Button IsCancel="True" HorizontalAlignment="Right" Width="70" Content="Cancel" Margin="0,0,10,0" VerticalAlignment="Center" Grid.Row="2" Command="{Binding Path=CancelCommand}" />
                <Button IsDefault="True" HorizontalAlignment="Right" Width="70" Content="OK" Margin="0,0,85,0" VerticalAlignment="Center" Grid.Row="2" d:LayoutOverrides="Height" Command="{Binding Path=AddCommand}" />
                <Border Grid.Row="1" Background="#FFFFFFFF">
                    <StackPanel>
                        <StackPanel Margin="10,10,10,0" Orientation="Horizontal">
                            <TextBox Text="{Binding Path=SearchText, UpdateSourceTrigger=PropertyChanged}" TextChanged="OnUserNameChanged" TextWrapping="NoWrap" Width="286" HorizontalAlignment="Stretch" Name="txtUserName" />
                            <Button Width="70" Content="Search" Margin="5,0,0,0" HorizontalAlignment="Center" Command="{Binding Path=SearchCommand}"/>
                        </StackPanel>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                            </Grid.RowDefinitions>
                        <TextBlock Visibility="{Binding  Path=HasNoUser, Converter={StaticResource VisibilityConverter}}"
                                            Text="No items match your search" Opacity="0.7" HorizontalAlignment="Center" VerticalAlignment="Center" AutomationProperties.AutomationId="AIdNoItems"
                                              Grid.Row="0"    Margin="0,5,0,5"/>
                       
						<ListView Visibility="{Binding  Path=HasUser, Converter={StaticResource VisibilityConverter}}" IsSynchronizedWithCurrentItem="True" BorderBrush="#FFCCCCCC" Margin="10,10,10,10" Height="150" ScrollViewer.VerticalScrollBarVisibility="Visible"
                                  ItemsSource="{Binding Path=SearchResults}" AutomationProperties.AutomationId="AIDUserList" SelectionChanged="OnUserSelectionChanged"
                               Grid.Row="1" >
							<ListView.View>
                                <GridView>
                                    <GridViewColumn  >
                                        <GridViewColumn.Header>
                                            <TextBlock Text="Name"  AutomationProperties.Name="ANameUserName" MinWidth="150"/>
                                    </GridViewColumn.Header>

                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Path=UserName}" ToolTip="{Binding Path=UserName}"  TextTrimming="CharacterEllipsis" MaxHeight="15" AutomationProperties.Name="{Binding Path=UserName}" />
                                                                    </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>

										
						</ListView>
                            </Grid>
					</StackPanel>
                </Border>
            </Grid>
        </Border>
    </Grid>
</Window>